package com.gardenguell.salad.ui.adapter;

import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.gardenguell.salad.R;
import com.gardenguell.salad.data.model.History;
import com.makeramen.roundedimageview.RoundedImageView;

import java.util.Collections;
import java.util.List;

/**
 * Created by absurd on 16/4/27.
 */
public class HistoryAdapter extends ClickableRecyclerViewAdapter{

    private List<History> mData = Collections.emptyList();

    public HistoryAdapter(List<History> data) {
        if(data != null)
            this.mData = data;
    }


    public void setData(List<History> data){
        this.mData = data;
        notifyDataSetChanged();
    }


    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_history, parent, false);
        view.setOnClickListener(this);
        return new ItemViewHolder(view);
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {

    }

    @Override
    public int getItemCount() {
        return mData.size();
    }

    public static class ItemViewHolder extends RecyclerView.ViewHolder{
        public ImageView photo;
        public RoundedImageView avatar;
        public TextView username;
        public TextView created;
        public TextView content;

        public ItemViewHolder(View itemView) {
            super(itemView);
            photo = (ImageView)itemView.findViewById(R.id.iv_photo);
            avatar = (RoundedImageView) itemView.findViewById(R.id.iv_avatar);
            username = (TextView)itemView.findViewById(R.id.tv_title_username);
            created = (TextView) itemView.findViewById(R.id.tv_title_created);
            content = (TextView) itemView.findViewById(R.id.tv_content);

        }
    }
}
